package regpang.myapplication22.dialog;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;

import com.coszero.utilslibrary.utils.ToastUtils;

import java.util.ArrayList;

import regpang.myapplication22.R;

/**
 * 显示Dialog弹窗
 */
public class DialogShowActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog_show);
    }

    public void select(View view) {
        switch (view.getId()) {
            case R.id.button7://显示FragmentDialog
                DialogForFragment dialogForFragment = DialogForFragment.newInstance();
                dialogForFragment.show(getSupportFragmentManager(), "DialogFragment");
                break;
            case R.id.button8:
                PopupWindowDialog popupWindowDialog = new PopupWindowDialog(this, new ArrayList<String>(), 0);
                popupWindowDialog.setOnTextSelectListener(new PopupWindowDialog.OnTextSelectListener() {
                    @Override
                    public void onTextSelect(String deviceTypeName) {
                        ToastUtils.showMsg(deviceTypeName);
                    }
                });
                if (!isFinishing() && !popupWindowDialog.isShowing()) {
                    popupWindowDialog.showAtLocation(getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);
                }
                break;
        }
    }
}
